package com.ekgc.addressbook.dao.mapper;


import com.ekgc.addressbook.common.UserInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    @Insert("INSERT INTO user_info (user_name, phone_number, user_password, gender, birth_date, email, address, create_time, update_time) " +
            "VALUES (#{userName}, #{phoneNumber}, #{userPassword}, #{gender}, #{birthDate}, #{email}, #{address}, #{createTime}, #{updateTime})")
    void insertUser(UserInfo userInfo);

    @Select("SELECT * FROM user_info WHERE phone_number = #{PhoneNumber}")
    UserInfo selectUserByPhoneNumber(String PhoneNumber);

    /**
     * 根据分组 ID 删除分组（物理删除）
     * @param groupId 分组 ID
     * @return 删除的记录数
     */
    @Delete("DELETE FROM user_group WHERE id = #{groupId}")
    int deleteUserGroupById(Integer groupId);

}